package losrebellos.papervision3d.objects.parsers 
{
	import org.papervision3d.events.FileLoadEvent;
	import org.papervision3d.materials.utils.MaterialsList;

	/*
	 *
	 * @author los rebellos - ben@benoitvinay.com
	 *
	 */
	public class SimpleDAE extends DAEPlus
	{
		/*
		 * 
		 * VARIABLES
		 * 
		 */
		protected var _modelXML:XML;
		protected var _materialsList:MaterialsList;
		protected var _animationDefaultStart:Number = 0;
		
		
		/*
		 *
		 * CONSTRUCTOR
		 *
		 */
		public function SimpleDAE(name:String = null)
		{
			super(false, name, false);
			
			createMaterialsList();
			createModel();
		}

		
		/*
		 * 
		 * 3D
		 * 
		 */
		protected function createMaterialsList():void
		{
			_materialsList = new MaterialsList();
		}
		protected function createModel():void
		{
			this.addEventListener(FileLoadEvent.LOAD_COMPLETE, loadCompleteHandler);
			this.load(_modelXML, _materialsList);
		}
		protected function loadCompleteHandler(e:FileLoadEvent):void
		{
			this.removeEventListener(FileLoadEvent.LOAD_COMPLETE, loadCompleteHandler);
			
			this.animation.progress = _animationDefaultStart;
		}
	}
}